02. basic_function
 Example about full variable table and function. Full variable and Light variable
are not explictly defined. They are just a convention which I thought would ease
the development of EUD script.

 With trigger programming, you can group a chunk of functionallity to a function,
which can be called multiple times anywhere when it's needed. Functions are ac-
tually called, rather than copied to needed places. Function calling with retaddr
full variable technique don't support recursive function. add.eud has an addition
function f_add and a full variable table vt.

-------

// Function storing add
Trigger: @vt
	next @vt_next
	Actions:

		// Do calculation. Actions are disabled by default
		; SetDeaths(0, SetTo, 0, 0) @A+20 @Aplayer+16 @Amodtype+24 @Asuspend+28
		; SetDeaths(0, SetTo, 0, 0) @B+20 @Bplayer+16 @Bmodtype+24 @Bsuspend+28
		; SetDeaths(0, SetTo, 0, 0) @ret+20 @retplayer+16 @retmodtype+24 @retsuspend+28
		; SetDeaths(0, SetTo, 0, 0) @retaddr+20 @retaddr_player+16 @retaddr_modtype+24 @retaddr_suspend+28
		
		// Disable vt
		SetDeaths(&Asuspend, SetTo, 2, 0)
		SetDeaths(&Bsuspend, SetTo, 2, 0)
		SetDeaths(&retsuspend, SetTo, 2, 0)
		SetDeaths(&retaddr_suspend, SetTo, 2, 0)



Each disabled SetDeaths action represents a full variable.
 ; SetDeaths(player, modtype, number, 0)
   - player  : Target address in epd player.
   - modtype : Method of modifing the target address.
   - number  : Modifier number. Variable value are stored in number section.


 Assume that we have a full variable A. then

                                         --player- --number- -modtype- -suspended-
 0000 0000 0000 0000 0000 0000 0000 0000 PPPP PPPP NNNN NNNN 0000 2DMM II00 0000
                                         --player- --number-        md ds
 (md : modtype, ds : action flag which also containes enabled state.)

   - player  field of SetDeaths A is at offset A+16
   - modtype field of SetDeaths A is at offset A+24
   - number  field of SetDeaths A is at offset A+20
   - disabled flag of SetDeaths A is at offset A+28


To assign/add/subtract value of A to address B, make
  - SetDeaths(&(A + 16), SetTo, &B, 0);
  - SetDeaths(&(A + 24), SetTo, 0x072D0000, 0);  // 0000 2D 07 in little endian = 0x072D0000
  - SetDeaths(&(A + 28), SetTo, 0, 0); // 00 00 00 00 in little endian = 0. Set action flag to 0.


 Every assignment in eudasm examples follows the above format. As Starcraft
trigger engine executes full variable table, Full variable A (as a SetDeaths
action) executes to our desire. Variable are automatically disabled right after
their execution, so that they won't have effect while other variables are being
used.

-------

 Function calls are done with retaddr full variable. It's just another convention
for ease of programming. When calling function f, the following happens.

  - f.retaddr = (trigger to return after the function executes)
    -> f executes
    (in f) f.vt_next = f.retaddr, lasttrigger.next = vt
    -> f.vt
  -> (desired return address)

-------

 This example uses three files to construct a program.
  - add.eud  : Implements basic addition function.
  - main.eud : Calls add.eud
  - compile.bat : Calls eudasm to link two eud files with the map.


compile.bat works as followings.
..\..\eudasm main.eud add.eud -o multi.scx --injector 6 --executer 7

  eudasm : Main linker
  main.eud add.eud : main.eud and add.eud are compiled and linked in the final binary in this order.
  -o multi.scx : Output target is 'multi.scx'. This map is copied to 'multi g.scx' and are linked with generated triggers.
  --injector 6, --executer 7 : Two players needed for execution of eudasm payload. It's recommended that these players are
   computers. These player are nessecary to be in the game. (If there are a single human player, that would be fine also.)


 main.eud is 4816 bytes, so main.eud and add.eud are each placed at base+0
and base+4816. (base : final compiled trigger) and all the addresses prefixed
with add: are offsetted by 4816 bytes.